#include "app_buffer.h"
#include "log/log.h"

int main(int argc, char const *argv[])
{
    /*
        创建buffer的size=12
        写1：abcd        abcd
        写2：efghi       abcdefghi
        读1：abcd        abcdefghi
        写3：jklmno      mnodefghijkl
        读2：efghi       mnodefghijkl
        读3：jklmno      mnodefghijkl

    */
    Buffer *buffer = app_buffer_init(12);
    app_buffer_write(buffer, "abcd", 4);
    app_buffer_write(buffer, "efghi", 5);
    char data1[4];
    app_buffer_read(buffer, data1, 4);
    log_debug("data1: %s", data1);
    app_buffer_write(buffer, "jklmno", 6);
    char data2[5];
    app_buffer_read(buffer, data2, 5);
    log_debug("data2: %s", data2);
    char data3[6];
    app_buffer_read(buffer, data3, 6);
    log_debug("data3: %s", data3);

    app_buffer_free(buffer);
    return 0;
}
